<?php
if (!defined('BASEPATH'))
	exit('No direct script access allowed');

class Date{
	public function format($time){
		if (is_string($time)){
			$time = strtotime($time);
		}
		if (is_numeric($time)) {
			$past = time() - $time;
			if(60> $past){
				$t = $past . '秒钟前';
			} elseif (3600 > $past){
				$t = round($past / 60).'分钟前';
			} elseif (86400 > $past){
				$t = round($past / 3600).'小时前';
			} elseif (604800 > $past){
				$t = round($past / 86400).'天前';
			} elseif ($past > 604800){
				$t = date('Y-m-d H:i:s', $time);
			} 
		}
		return $t;
	}
}
